*******************************************************
* Author: Michael Tomz
* Date: Dec 20, 2001
* Format: Stata do-file
* Purpose: Replicate Section 5.4 (Incumbency Advantage)
*******************************************************

version 6.0
clear
set mem 20m
tempfile ukinc

* PREPARE KK INCUMBENCY ESTIMATES FOR GRAPHING
infile year coneff1 coneff2 coneff3 labeff1 labeff2 labeff3 /*
   */ libeff1 libeff2 libeff3 using posteff.out
replace coneff1 = 100*coneff1
replace labeff2 = 100*labeff2
replace libeff3 = 100*libeff3
egen conplok = pctile(coneff1), p(2.5) by(year)
egen conpk = pctile(coneff1), p(50) by(year)
egen conphik = pctile(coneff1), p(97.5) by(year)
egen labplok = pctile(labeff2), p(2.5) by(year)
egen labpk = pctile(labeff2), p(50) by(year)
egen labphik = pctile(labeff2), p(97.5) by(year)
egen libplok = pctile(libeff3), p(2.5) by(year)
egen libpk = pctile(libeff3), p(50) by(year)
egen libphik = pctile(libeff3), p(97.5) by(year)
collapse conplok conpk conphik labplok labpk labphik libplok libpk libphik, by(year)
sort year
gen x = _n
gen str10 yearst = string(year)
replace yearst = "74a" if yearst=="74.9"  
sort yearst   
save `ukinc'

* PREPARE SUR INCUMBENCY ESTIMATES FOR GRAPHING
use if92, clear
append using if87
append using if83
append using if79
append using if74a
append using if74
append using if70
append using if66
append using if64
append using if59
egen conplo = pctile(coneff1), p(2.5) by(yearst)
egen conp = pctile(coneff1), p(50) by(yearst)
egen conphi = pctile(coneff1), p(97.5) by(yearst)
egen labplo = pctile(labeff2), p(2.5) by(yearst)
egen labp = pctile(labeff2), p(50) by(yearst)
egen labphi = pctile(labeff2), p(97.5) by(yearst)
egen libplo = pctile(libeff3), p(2.5) by(yearst)
egen libp = pctile(libeff3), p(50) by(yearst)
egen libphi = pctile(libeff3), p(97.5) by(yearst)
collapse conplo conp conphi labplo labp labphi libplo libp libphi, by(yearst)
sort yearst
merge yearst using `ukinc'
drop _merge year
save incumb, replace old

